package com.kuanter.kuanterauto.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.kuanter.kuanterauto.R;
import com.kuanter.kuanterauto.baseui.ProApplication;
import com.kuanter.kuanterauto.constants.MainConstants;
import com.kuanter.kuanterauto.main.HomeActivityGroup;

/**
 * 年审支付失败
 * @author kuanter
 *
 */
public class PayFailActivity extends Activity {
	RelativeLayout dj_payfail;
	TextView which_tc_fail;
	
	Button prepaid;  //充值
	
	public static int status_fail = -200;
	public static int status_success = 200;
	
	int currentStatus;
	
	String message_back;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.payfail);
		Intent intent = getIntent();
		int status = intent.getIntExtra("status", 0);
		message_back = intent.getStringExtra("message_back");
		if(status == status_fail) {
			currentStatus = status_fail;
		} else if(status == status_success) {
			currentStatus = status_success;
		}
		
		dj_payfail = (RelativeLayout) findViewById(R.id.dj_payfail);
		TextView title = (TextView) dj_payfail.findViewById(R.id.top_middle);
		
		LinearLayout home_chose_City = (LinearLayout) dj_payfail.findViewById(R.id.home_chose_City);
		home_chose_City.setVisibility(View.GONE);
		
		which_tc_fail = (TextView) findViewById(R.id.which_tc_fail);
		prepaid = (Button) findViewById(R.id.prepaid);
		
		if(currentStatus == status_fail) {
			title.setText("支付失败");
			which_tc_fail.setText(message_back);
			
			prepaid.setText("充值");
		} else if(currentStatus == status_success) {
			title.setText("申请成功");
			which_tc_fail.setText("恭喜您申请年审服务成功,稍后我们将短信通知您");
			prepaid.setText("返回会员中心");
		}
		
		
		prepaid.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				if(currentStatus == status_fail) {
//					Toast.makeText(PayFailActivity.this, "跳转到充值界面", 3000).show();
					Intent intent = new Intent(PayFailActivity.this, RechargeActivity.class);
					startActivity(intent);
				} else if(currentStatus == status_success) {
//					Toast.makeText(PayFailActivity.this, "跳转到会员中心", 3000).show();
					if(HomeActivityGroup.select_id != null) {
						HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
					}
					HomeActivityGroup.backAction = MainConstants.HY_ACTION;
					finish();
				}
			}
		});
	}
	
	public void exit(View view) {
		finish();
	}
	
}
